#include "stdafx.h"
#include "Game.h"




CGame::CGame(void)
{
	m_iSpritesLoaded=0;
	m_eGameState = eGameStateMenu;
	
}


CGame::~CGame(void)
{
}

//
//  FUNCTION: AddSprite
//
//  PURPOSE: adds a sprite into the array that contains all active sprites
//  ( a bit like addChild in Flash)
void
CGame::AddSprite(CSprite * pSprite_)
{
	m_pSprites[m_iSpritesLoaded++]=pSprite_;
}


//
//  FUNCTION: DoFrame()
//
//  PURPOSE: executes one loop of the main game loop.
//

void
CGame::DoFrame()
{
	//get input
	CInput::getInstance()->getInput(); //refresh input system

	//get dt
	float dt = CTimer::Instance()->Getdt();

	if (eGameStateMenu)
	{
		if (CInput::getInstance()->getIfKeyDown(DIK_SPACE))
		{
			m_eGameState = eGameStatePlay;
		}
	}

	//update

	for (int i = 0; i<m_iSpritesLoaded; i++)
	{
		m_pSprites[i]->update(dt);
	}

	//render


	for (int i=0; i<m_iSpritesLoaded ; i++)
	{
		m_pSprites[i]->render();
	}
}